//
//  YSMMainViewController.m
//  YSMWeibo
//
//  Created by 杨思明 on 16/7/24.
//  Copyright © 2016年 杨思明. All rights reserved.
//


#import "YSMMainTabBar.h"
#import "YSMMainViewController.h"
#import "YSMProflieTableViewController.h"
#import "YSMMessageTableViewController.h"
#import "YSMHomeTableViewController.h"
#import "YSMDiscoverTableViewController.h"
@interface YSMMainViewController ()

@end

@implementation YSMMainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
//    self.tabBar = [YSMMainTabBar new];
    [self setValue:[YSMMainTabBar new] forKey:@"tabBar"];
    
    [self addChildViewControllers];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(composeClick) name:@"YSMMainTabBar" object:nil];
    
}


-(void)composeClick{
    
    NSLog(@"11111");
}

-(void)addChildViewControllers{
    YSMHomeTableViewController *homeVC =[YSMHomeTableViewController new];
    [self addChildViewController:homeVC title:@"首页" imageName:@"tabbar_home"];
    
    [self addChildViewController:[YSMMessageTableViewController new] title:@"消息" imageName:@"tabbar_message_center"];
    [self addChildViewController:[YSMDiscoverTableViewController new] title:@"发现" imageName:@"tabbar_discover"];
    [self addChildViewController:[YSMProflieTableViewController new] title:@"我" imageName:@"tabbar_profile"];
    
}

-(void)addChildViewController:(UIViewController *)controller title:(NSString *)title imageName:(NSString *)imageName  {
    
    controller.title = title;
    controller.tabBarItem.image = [UIImage imageNamed:imageName];
   NSString *selected =  [imageName stringByAppendingString:@"_selected"];
    controller.tabBarItem.selectedImage = [[UIImage imageNamed:selected] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    self.tabBar.tintColor = [UIColor orangeColor];
    [self addChildViewController:[[UINavigationController alloc] initWithRootViewController:controller]];

}



@end
